﻿Imports System.Data.OleDb
Public Class StudentCalendar
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        lbl_selectedDate.Text = Calendar1.SelectedDate.DayOfWeek.ToString & ", " & getSelectedMonth() & " " & Calendar1.SelectedDate.Day & ", " & Calendar1.SelectedDate.Year
    End Sub

    Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Calendar1.SelectionChanged
        Response.Redirect("entry.aspx?AppointmentDate=" & CType(Calendar1.SelectedDate, Date))
        'lbl_selectedDate.Text = Calendar1.SelectedDate.DayOfWeek.ToString & ", " & getSelectedMonth() & " " & Calendar1.SelectedDate.Day & ", " & Calendar1.SelectedDate.Year
    End Sub

    Function getSelectedMonth()
        Dim selectedMonth As String = ""
        If Calendar1.SelectedDate.Month = 1 Then
            selectedMonth = "January"
        ElseIf Calendar1.SelectedDate.Month = 2 Then
            selectedMonth = "February"
        ElseIf Calendar1.SelectedDate.Month = 3 Then
            selectedMonth = "March"
        ElseIf Calendar1.SelectedDate.Month = 4 Then
            selectedMonth = "April"
        ElseIf Calendar1.SelectedDate.Month = 5 Then
            selectedMonth = "May"
        ElseIf Calendar1.SelectedDate.Month = 6 Then
            selectedMonth = "June"
        ElseIf Calendar1.SelectedDate.Month = 7 Then
            selectedMonth = "July"
        ElseIf Calendar1.SelectedDate.Month = 8 Then
            selectedMonth = "August"
        ElseIf Calendar1.SelectedDate.Month = 9 Then
            selectedMonth = "September"
        ElseIf Calendar1.SelectedDate.Month = 10 Then
            selectedMonth = "October"
        ElseIf Calendar1.SelectedDate.Month = 11 Then
            selectedMonth = "November"
        ElseIf Calendar1.SelectedDate.Month = 12 Then
            selectedMonth = "December"
        Else
            selectedMonth = "No month is selected"
        End If
        Return selectedMonth
    End Function


    ''Protected Sub btn_submit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_submit.Click
    ''Dim item As ListItem
    '' Dim conn As New OleDbConnection(ConfigurationManager.ConnectionStrings("AppointmentsConnectionString").ToString())
    ''For Each item In CheckBoxList1.Items
    ''Dim sql As String = "INSERT INTO Slots(Lecturer, AppointmentSlots) VALUES(@Lecturer, @AppointmentSlots)"
    '' Dim cmd As New OleDbCommand(sql, conn)
    '' If item.Selected = True Then
    ''conn.Open()
    '' cmd.Parameters.AddWithValue("@Lecturer", User.Identity.Name)
    ''  cmd.Parameters.AddWithValue("@AppointmentSlots", item.Value)
    ''  Label1.Text = Label1.Text.ToString & item.Text & "<BR>"
    '' cmd.ExecuteNonQuery()
    ''  conn.Close()
    '' End If
    '' Next
    'If CheckBox1.Checked And CheckBox2.Checked Then

    ''End Sub
End Class